import { apiClient, ApiResponse } from "../lib/api";

export interface LoginKaptchaBody {
  phoneNumber: string;
  kaptchaKey: string;
  kaptchaValue: string;
}

export interface LoginAppBody {
  username: string;
  password: string;
  uuid: string;
  code: string;
}

export interface loginToken {
  token: string;
  add?: boolean;
}

// 用户类型定义
export interface User {
  id: string;
  phonenumber: string;
  nickName?: string;
  avatar?: string;
  credits: number;
  isProfileComplete: boolean;
}

interface UserRespose extends ApiResponse {
  user: User;
}

export async function getUserInfo(): Promise<UserRespose> {
  return await apiClient.get("/getInfo");
}

export async function regAndLogin(
  params: LoginKaptchaBody
): Promise<ApiResponse<loginToken>> {
  return apiClient.post<loginToken>("/app/reg-and-login", params);
}

export async function LoginApp(params: LoginAppBody) {
  return apiClient.post<loginToken>("/app/login", params);
}

export async function logoutSys() {
  return apiClient.post("/logout");
}

export async function changePwd(params: any) {}

export async function updateUse(params: any) {}
